home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmgi.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  4.7 KB  |  204 lines

  1. #ifndef    H_RPMGI
  2. #define    H_RPMGI
  3.  
  4. /** \ingroup rpmio
  5.  * \file lib/rpmgi.h
  6.  */
  7.  
  8. #include <rpmlib.h>
  9. #include <rpmte.h>
  10. #include <rpmts.h>
  11. #include <fts.h>
  12. #include <argv.h>
  13.  
  14. /**
  15.  */
  16. /*@-exportlocal@*/
  17. /*@unchecked@*/
  18. extern int _rpmgi_debug;
  19. /*@=exportlocal@*/
  20.  
  21. /**
  22.  */
  23. typedef enum rpmgiFlags_e {
  24.     RPMGI_NONE        = 0,
  25.     RPMGI_TSADD        = (1 << 0),
  26.     RPMGI_TSORDER    = (1 << 1),
  27.     RPMGI_NOGLOB    = (1 << 2),
  28.     RPMGI_NOMANIFEST    = (1 << 3),
  29.     RPMGI_NOHEADER    = (1 << 4)
  30. } rpmgiFlags;
  31.  
  32. /*@unchecked@*/
  33. extern rpmgiFlags giFlags;
  34.  
  35. #if defined(_RPMGI_INTERNAL)
  36. /** \ingroup rpmio
  37.  */
  38. struct rpmgi_s {
  39. /*@refcounted@*/
  40.     rpmts ts;            /*!< Iterator transaction set. */
  41.     int tag;            /*!< Iterator type. */
  42. /*@kept@*/ /*@relnull@*/
  43.     const void * keyp;        /*!< Iterator key. */
  44.     size_t keylen;        /*!< Iterator key length. */
  45.  
  46.     rpmgiFlags flags;        /*!< Iterator control bits. */
  47.     int active;            /*!< Iterator is active? */
  48.     int i;            /*!< Element index. */
  49.     int errors;            /*!< No. errors encountered on iteration */
  50. /*@null@*/
  51.     const char * hdrPath;    /*!< Path to current iterator header. */
  52. /*@refcounted@*/ /*@null@*/
  53.     Header h;            /*!< Current iterator header. */
  54.  
  55. /*@null@*/
  56.     rpmtsi tsi;
  57.  
  58. /*@null@*/
  59.     rpmdbMatchIterator mi;
  60.  
  61. /*@refcounted@*/
  62.     FD_t fd;
  63.  
  64.     ARGV_t argv;
  65.     int argc;
  66.  
  67.     int ftsOpts;
  68. /*@null@*/
  69.     FTS * ftsp;
  70. /*@relnull@*/
  71.     FTSENT * fts;
  72.  
  73. /*@refs@*/
  74.     int nrefs;            /*!< Reference count. */
  75. };
  76. #endif
  77.  
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81.  
  82. /**
  83.  * Unreference a generalized iterator instance.
  84.  * @param gi        generalized iterator
  85.  * @param msg
  86.  * @return        NULL always
  87.  */
  88. /*@unused@*/ /*@null@*/
  89. rpmgi rpmgiUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmgi gi,
  90.         /*@null@*/ const char * msg)
  91.     /*@modifies gi @*/;
  92.  
  93. /** @todo Remove debugging entry from the ABI. */
  94. /*@-exportlocal@*/
  95. /*@null@*/
  96. rpmgi XrpmgiUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmgi gi,
  97.         /*@null@*/ const char * msg, const char * fn, unsigned ln)
  98.     /*@modifies gi @*/;
  99. /*@=exportlocal@*/
  100. #define    rpmgiUnlink(_gi, _msg)    XrpmgiUnlink(_gi, _msg, __FILE__, __LINE__)
  101.  
  102. /**
  103.  * Reference a generalized iterator instance.
  104.  * @param gi        generalized iterator
  105.  * @param msg
  106.  * @return        new generalized iterator reference
  107.  */
  108. /*@unused@*/ /*@newref@*/ /*@null@*/
  109. rpmgi rpmgiLink (/*@null@*/ rpmgi gi, /*@null@*/ const char * msg)
  110.     /*@modifies gi @*/;
  111.  
  112. /** @todo Remove debugging entry from the ABI. */
  113. /*@newref@*/ /*@null@*/
  114. rpmgi XrpmgiLink (/*@null@*/ rpmgi gi, /*@null@*/ const char * msg,
  115.         const char * fn, unsigned ln)
  116.         /*@modifies gi @*/;
  117. #define    rpmgiLink(_gi, _msg)    XrpmgiLink(_gi, _msg, __FILE__, __LINE__)
  118.  
  119. /** Destroy a generalized iterator.
  120.  * @param gi        generalized iterator
  121.  * @return        NULL always
  122.  */
  123. /*@null@*/
  124. rpmgi rpmgiFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmgi gi)
  125.     /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
  126.         /*@modifies gi, rpmGlobalMacroContext, h_errno, internalState @*/;
  127.  
  128. /**
  129.  * Return a generalized iterator.
  130.  * @param ts        transaction set
  131.  * @param tag        rpm tag
  132.  * @param keyp        key data (NULL for sequential access)
  133.  * @param keylen    key data length (0 will use strlen(keyp))
  134.  * @return        new iterator
  135.  */
  136. /*@null@*/
  137. rpmgi rpmgiNew(rpmts ts, int tag, /*@kept@*/ /*@null@*/ const void * keyp,
  138.         size_t keylen)
  139.     /*@globals internalState @*/
  140.     /*@modifies ts, internalState @*/;
  141.  
  142. /**
  143.  * Perform next iteration step.
  144.  * @param gi        generalized iterator
  145.  * @returns        RPMRC_OK on success, RPMRC_NOTFOUND on EOI
  146.  */
  147. rpmRC rpmgiNext(/*@null@*/ rpmgi gi)
  148.     /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
  149.         /*@modifies gi, rpmGlobalMacroContext, h_errno, internalState @*/;
  150.  
  151. /**
  152.  * Return current header path.
  153.  * @param gi        generalized iterator
  154.  * @returns        header path
  155.  */
  156. /*@observer@*/ /*@null@*/
  157. const char * rpmgiHdrPath(rpmgi gi)
  158.     /*@*/;
  159.  
  160. /**
  161.  * Return current iteration header.
  162.  * @param gi        generalized iterator
  163.  * @returns        header
  164.  */
  165. /*@null@*/
  166. Header rpmgiHeader(/*@null@*/ rpmgi gi)
  167.         /*@*/;
  168.  
  169. /**
  170.  * Return current iteration transaction set.
  171.  * @param gi        generalized iterator
  172.  * @returns        transaction set
  173.  */
  174. /*@null@*/
  175. rpmts rpmgiTs(/*@null@*/ rpmgi gi)
  176.         /*@*/;
  177.  
  178. /**
  179.  * Load iterator args.
  180.  * @param gi        generalized iterator
  181.  * @param argv        arg list
  182.  * @param ftsOpts    fts(3) flags
  183.  * @param flags        iterator flags
  184.  * @returns        RPMRC_OK on success
  185.  */
  186. rpmRC rpmgiSetArgs(rpmgi gi, /*@null@*/ ARGV_t argv,
  187.         int ftsOpts, rpmgiFlags flags)
  188.     /*@globals internalState @*/
  189.     /*@modifies gi, internalState @*/;
  190.  
  191. /** \ingroup rpmgi
  192.  * Return number of errors (file not found etc) encountered during iteration
  193.  * @param gi           generalized iterator
  194.  * @return             number of errors
  195.  */
  196. int rpmgiNumErrors(rpmgi gi);
  197.  
  198.  
  199. #ifdef __cplusplus
  200. }
  201. #endif
  202.  
  203. #endif    /* H_RPMGI */
  204.